<?php
      include_once "blog.php";  
      $connection = connect($config);
	  
	  if(isset($_GET['page']))
	   {$page=$_GET['page']-1;
	    $limit=($_GET['page']-1)*10;
		  if($limit==0)
		      {$limit1=10;}
		  else
		      {$limit1=$limit;}}
	   else
	   {$page=0;
	    $limit=0;
		$limit1=10;}
		
	  $counttitle=$page*10+1;

      $posts = getAllPosts($connection,$limit,$limit1);
	  $count=count($posts);
	  $posts1 = getAll($connection);
	  $count1=count($posts1);
	  
	  $articlesperPage=10;
      $pageLinksCount =  $count1 /  $articlesperPage;
	  $pageLinksCount = ceil( $pageLinksCount );
	  
	  
	  
      view("index", array( 'posts' => $posts,'counttitle'=>$counttitle,'pageLinksCount'=>$pageLinksCount) );
	  
?>